package com.heima.wemedia.controller.v1;

import com.heima.model.common.dto.PageResponseResult;
import com.heima.model.common.dto.ResponseResult;
import com.heima.model.wemedia.dto.WmPageRequestDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/api/v1/material")
@Slf4j
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) throws IOException {
        log.info("upload_picture:{}", multipartFile);
        return wmMaterialService.uploadPicture(multipartFile);
    }

    @PostMapping("/list")
    public PageResponseResult list(@RequestBody WmPageRequestDto dto){
        log.info("list:{}", dto);
        return wmMaterialService.queryByPage(dto);
    }

}
